#pragma once

#include <Windows.h>
#include <string>

#include "..\Scrabble_Client\ClientSettings.h"

using namespace std;

class BoardManager
{
private:
	char mLetters[ClientSettings::BOARD_NLINES * ClientSettings::BOARD_NCOLS];
	bool mTileLocks[ClientSettings::BOARD_NLINES * ClientSettings::BOARD_NCOLS];
	UINT mLockedLines;
	HANDLE mAccessSem;

private:
	static inline UINT CoordsToPos(UINT _line, UINT _col);


public:
	BoardManager(void);

	bool LockPosition(UINT _line, UINT _col, char _letter);
	void UnlockPosition(UINT _line, UINT _col);
	void Reset();
	string GetLineWord(UINT _line, UINT& _remaingFreeTiles, UINT& _startFreeTiles);

	bool IsLineEmpty(UINT _line);

	void IncLockedLines();

	bool HasFreeLines();
};

